package hibernatemock;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class Defaults {

	public static FluentApi get() {
		FluentApi fluentApi = new FluentApi();
		string(fluentApi);
		primitiveAndWrappers(fluentApi);
		bigdecimal(fluentApi);
		date(fluentApi);
		calendar(fluentApi);
		sqlDate(fluentApi);
		time(fluentApi);
		timeStamp(fluentApi);
		collections(fluentApi);
		maps(fluentApi);
		arrays(fluentApi);
		return fluentApi;
	}

	private static void timeStamp(FluentApi fluentApi) {
		fluentApi.putKey(Timestamp.class).putValue(new Timestamp(0));
	}

	private static void time(FluentApi fluentApi) {
		fluentApi.putKey(Time.class).putValue(new Time(0));
	}

	private static void sqlDate(FluentApi fluentApi) {
		fluentApi.putKey(java.sql.Date.class).putValue(new java.sql.Date(0));
	}

	private static void calendar(FluentApi fluentApi) {
		fluentApi.putKey(Calendar.class).putValue(getCalendarDate0());
	}

	private static void date(FluentApi fluentApi) {
		fluentApi.putKey(Date.class).putValue(new Date(0));
	}

	private static void bigdecimal(FluentApi fluentApi) {
		fluentApi.putKey(BigInteger.class).putValue(new BigInteger("0"));
		fluentApi.putKey(BigDecimal.class).putValue(new BigDecimal("0"));
	}

	private static void arrays(FluentApi fluentApi) {
		fluentApi.putKey(byte[].class).putValue(new byte[] { 0x00 });
		fluentApi.putKey(char[].class).putValue(new char[] { '0' });
		fluentApi.putKey(Byte[].class).putValue(new Byte[] { 0x00 });
		fluentApi.putKey(Character[].class).putValue(new Character[] { '0' });
	}

	private static void maps(FluentApi fluentApi) {
		fluentApi.putKey(Map.class).putValue(new HashMap<Object, Object>());
		fluentApi.putKey(HashMap.class).putValue(new HashMap<Object, Object>());
		fluentApi.putKey(LinkedHashMap.class).putValue(new LinkedHashMap<Object, Object>());
	}

	private static void primitiveAndWrappers(FluentApi fluentApi) {
		fluentApi.putKey(boolean.class).putValue(new Boolean(false));
		fluentApi.putKey(byte.class).putValue(new Byte((byte) 0));
		fluentApi.putKey(char.class).putValue(new Character((char) 0));
		fluentApi.putKey(short.class).putValue(new Short((short) 0));
		fluentApi.putKey(int.class).putValue(0);
		fluentApi.putKey(long.class).putValue(0L);
		fluentApi.putKey(float.class).putValue(0F);
		fluentApi.putKey(double.class).putValue(0D);
		fluentApi.putKey(Boolean.class).putValue(new Boolean(false));
		fluentApi.putKey(Byte.class).putValue(new Byte((byte) 0));
		fluentApi.putKey(Character.class).putValue(new Character((char) 0));
		fluentApi.putKey(Short.class).putValue(new Short((short) 0));
		fluentApi.putKey(Integer.class).putValue(0);
		fluentApi.putKey(Long.class).putValue(0L);
		fluentApi.putKey(Float.class).putValue(0F);
		fluentApi.putKey(Double.class).putValue(0D);
	}

	private static void collections(FluentApi fluentApi) {
		fluentApi.putKey(Collection.class).putValue(new ArrayList<Object>());
		fluentApi.putKey(List.class).putValue(new ArrayList<Object>());
		fluentApi.putKey(ArrayList.class).putValue(new ArrayList<Object>());
		fluentApi.putKey(LinkedList.class).putValue(new LinkedList<Object>());
		fluentApi.putKey(Set.class).putValue(new HashSet<Object>());
		fluentApi.putKey(HashSet.class).putValue(new HashSet<Object>());
		fluentApi.putKey(LinkedHashSet.class).putValue(new LinkedHashSet<Object>());
	}

	private static void string(FluentApi fluentApi) {
		fluentApi.putKey(String.class).putValue("");
	}

	private static Calendar getCalendarDate0() {
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(new Date(0));
		return calendar;
	}

}
